package org.springblade.modules.notice.core.conditon.impl;

import org.springblade.modules.notice.core.conditon.TriggerConditionFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author ysq
 * @Date 2024/12/06
 * @Description 任务签到时，电梯状态“已停梯”变更至“正常”
 */
@Component
public class Condition9Handler implements TriggerConditionFactory {

	@Resource
	private JdbcTemplate jdbcTemplate;

	private static final String C_9_SQL = "SELECT t2.is_stop = 1 FROM blade_maintain_plan_content t1 INNER JOIN blade_elevator t2 ON t1.elevator_id = t2.id WHERE t1.id = ?";

	@Override
	public boolean isTrigger(Long bizId) {
		try {
			return jdbcTemplate.queryForObject(C_9_SQL, new Object[]{bizId}, boolean.class);
		} catch (DataAccessException e) {
			return false;
		}
	}
}
